import HttpUtil from '@/common/HttpUtil'

const menuApi = {
  addMenu (params) {
    let postUrl = process.env.SURVEY_DOMAIN + '/sys/menu/addMenu'
    return HttpUtil.postJSON(postUrl, params)
  },
  getMenu (id) {
    let postUrl = process.env.SURVEY_DOMAIN + '/sys/menu/getMenu/' + id
    return HttpUtil.get(postUrl, '')
  },
  updateMenu (params) {
    let putUrl = process.env.SURVEY_DOMAIN + '/sys/menu/updateMenu'
    return HttpUtil.putJSON(putUrl, params)
  },
  deleteMenu (id) {
    let getUrl = process.env.SURVEY_DOMAIN + '/sys/menu/deleteMenu/' + id
    return HttpUtil.delete(getUrl, null)
  },
  findMenu () {
    let getUrl = process.env.SURVEY_DOMAIN + '/sys/menu/findMenu'
    return HttpUtil.postJSON(getUrl, null)
  },
  saveRoleMenu (params) {
    let getUrl = process.env.SURVEY_DOMAIN + '/sys/role/saveRoleMenu'
    return HttpUtil.postJSON(getUrl, params)
  },
  findMenuPage (params) {
    let getUrl = process.env.SURVEY_DOMAIN + '/sys/menu/findMenuPage'
    return HttpUtil.postJSON(getUrl, params)
  },
  findRoleMenu (params) {
    let getUrl = process.env.SURVEY_DOMAIN + '/sys/role/findRoleMenu'
    return HttpUtil.postJSON(getUrl, params)
  },
  findMenuList () {
    let url = process.env.SURVEY_DOMAIN + '/sys/menu/findMenuList'
    return HttpUtil.post(url, null)
  }
}

export default menuApi
